/*
package com.ruoyi.runner;

import com.ruoyi.order.domain.MesDetectNode;
import com.ruoyi.order.service.IConfigService;
import com.ruoyi.order.service.IMesDetectNodeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.concurrent.atomic.AtomicReference;

@Order(3)
@Component
@Slf4j
public class SingleStationRunner implements ApplicationRunner {

    @Autowired
    private ScanPLCService scanPLCService;

    @Autowired
    private IMesDetectNodeService detectNodeService;
    @Autowired
    private IConfigService configService;

    */
/**
     * 启动项目时启动多线程,每个线程循环执行一个节点
     *
     * @param args
     * @throws Exception
     *//*

    @Override
    public void run(ApplicationArguments args) throws Exception {
        //操作指引扫描标志
        String operateFlag = configService.selectConfigByKey("plc_operate_flag");
        //生产数据扫描标志
        String productDataFlag = configService.selectConfigByKey("plc_product_data_flag");
        //操作指引定点扫描站号
        String scanNode = configService.selectConfigByKey("plc_product_data_node");
        //产线号
        String lineNumber = configService.selectConfigByKey("line_number");
        MesDetectNode param = new MesDetectNode();
        param.setSubsysCode(lineNumber);
        List<MesDetectNode> detectNodeList = detectNodeService.selectMesDetectNodeList(param);
        MesDetectNode detectNode = null;
        MesDetectNode firstNode = null;
        MesDetectNode LastNode = null;
        for (MesDetectNode mesDetectNode : detectNodeList){
            if (mesDetectNode.getNodeCode().equals(scanNode)){
                detectNode = mesDetectNode;
            }
            if (mesDetectNode.getSortIndex() == 1){
                firstNode = mesDetectNode;
            }
            if (mesDetectNode.getSortIndex() == detectNodeList.size()){
                LastNode = mesDetectNode;
            }
        }
        if(scanNode.equals("231")){
            return;
        }
        //循环实现扫描PLC 生产数据
        while (true) {
            if (productDataFlag.equals("true")) {
                log.info("执行 scanPLCService.handleNode,生产数据处理");
                if (scanNode.equals("27")){
                    scanPLCService.handleNode(firstNode, detectNodeList.size());
                    scanPLCService.handleNode(LastNode, detectNodeList.size());
                }else{
                    scanPLCService.handleNode(detectNode, detectNodeList.size());
                }
                try {
                    Thread.sleep(200);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            //循环实现扫描PLC 操作数据
            if (operateFlag.equals("true")) {
                log.info("执行 scanPLCService.operateGuide,操作指引数据处理");
                scanPLCService.operateGuide(detectNode);
                try {
                    Thread.sleep(200);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
*/
